﻿namespace ExamV5
{
    using System;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public class FrmLeftMenu : Page
    {
        protected HtmlForm form1;
        protected HtmlHead Head1;
        private int int_0 = 0;
        protected Label labMenu;
        private PublicFun publicFun_0 = new PublicFun();

        protected void Page_Load(object sender, EventArgs e)
        {
            base.Response.Expires = 0;
            this.int_0 = Convert.ToInt32(base.Request["UPID"]);
            if (!base.IsPostBack)
            {
                this.Page.Title = ConfigurationManager.ConnectionStrings["ProTitle"].ConnectionString;
                string str5 = "";
                if (!(base.Server.UrlDecode(base.Request.Cookies["ExamUserLevel"].Value) == "A"))
                {
                    str5 = " and ";
                }
                else
                {
                    str5 = " and IsShow='A' and ";
                }
                this.labMenu.Text = "<div class=\"side_nav\">";
                string cmdText = "";
                string str2 = "";
                if (this.int_0 != 0)
                {
                    cmdText = string.Concat(new object[] { "select MenuTitle,TrgetFlag,MenuURL,MenuICO from SysMenu where UPID=", this.int_0, str5, " IsHide='N' and (BrowUserCode like '%,所有人员,%' or BrowUserCode like '%,", this.publicFun_0.CheckString(base.Server.UrlDecode(base.Request.Cookies["ExamUserCode"].Value)), ",%') order by MenuSort" });
                }
                else if (!(base.Server.UrlDecode(base.Request.Cookies["ExamUserLevel"].Value) == "A"))
                {
                    cmdText = "select MenuTitle,TrgetFlag,MenuURL,MenuICO from SysMenu where UPID<>0 and  (MenuTitle like '%教材管理%' or MenuTitle like '%课件管理%' or MenuTitle like '%考试题库%' or MenuTitle like '%试卷信息管理%' or MenuTitle like '%监考%' or MenuTitle like '%成绩管理%' or MenuTitle like '%人员信息管理%') " + str5 + " IsHide='N' and (BrowUserCode like '%,所有人员,%' or BrowUserCode like '%," + this.publicFun_0.CheckString(base.Server.UrlDecode(base.Request.Cookies["ExamUserCode"].Value)) + ",%') order by MenuSort";
                }
                else
                {
                    cmdText = "select MenuTitle,TrgetFlag,MenuURL,MenuICO from SysMenu where UPID<>0 and  (MenuTitle like '我的个人%' or MenuTitle like '我的成绩%' or MenuTitle like '%电子教材中心%' or MenuTitle like '%电子课件中心%' or MenuTitle like '%在线练习中心%' or MenuTitle like '%学习笔记%' or MenuTitle like '%在线考试中心%') " + str5 + " IsHide='N' and (BrowUserCode like '%,所有人员,%' or BrowUserCode like '%," + this.publicFun_0.CheckString(base.Server.UrlDecode(base.Request.Cookies["ExamUserCode"].Value)) + ",%') order by MenuSort";
                }
                int num = 0;
                string str = "";
                SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
                connection.Open();
                SqlCommand command = new SqlCommand(cmdText, connection);
                SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                while (reader.Read())
                {
                    if (!(reader["TrgetFlag"].ToString().Trim() == "Y"))
                    {
                        str2 = "window.parent.MainFrame.location.href";
                    }
                    else
                    {
                        str2 = "window.parent.location.href";
                    }
                    if (num == 0)
                    {
                        str = reader["MenuURL"].ToString();
                    }
                    //this.labMenu.Text = this.labMenu.Text + "<tr><td background='" + reader["MenuICO"].ToString() + "' width='111' height='87'  onmousemove=this.style.cursor='hand'  onmouseover=javascript:BGChanged(this,0); onmouseout=javascript:BGChanged(this,1); align='center' onclick=javascript:" + str2 + "='" + reader["MenuURL"].ToString() + "'; valign='bottom'>" + reader["MenuTitle"].ToString() + "</td></tr>";

                    string url = str2 + "='" + reader["MenuURL"].ToString() + "'";
                    this.labMenu.Text = this.labMenu.Text + "<a  href=\"#\" onclick=javascript:" + url + ">";
                    this.labMenu.Text = this.labMenu.Text + "<dl>";
                    this.labMenu.Text = this.labMenu.Text + "<dt><img src=\"" + reader["MenuICO"].ToString() + "\" /></dt>";
                    this.labMenu.Text = this.labMenu.Text + "<dd>" + reader["MenuTitle"].ToString() + "</dd>";
                    this.labMenu.Text = this.labMenu.Text + "</dl>";
                    this.labMenu.Text = this.labMenu.Text + "</a>";

                    num++;
                }
                reader.Close();
                command.Dispose();
                connection.Close();
                connection.Dispose();
                this.labMenu.Text = this.labMenu.Text + "</div>";
                if (!((this.int_0 != 0) ? !(str.Trim() != "") : true))
                {
                    base.Response.Write("<script>window.parent.MainFrame.location.href='" + str + "'</script>");
                }
            }
        }
    }
}

